/*
 * @Author: huangyingli
 * @Date: 2023-02-24 10:57:56
 * @LastEditors: huangyingli
 * @LastEditTime: 2023-02-24 15:50:14
 * @Description:
 */

import { forwardRef, lazy, Suspense } from 'react';
import { Form } from 'antd';
const GetComponent = {
  Input: lazy((props) => {
    return import('./formComponent/CInput');
  }),
  CList: lazy((props) => {
    return import('./formComponent/CList');
  }),
};

function switchComponent(props) {
  switch (props.config.ui.component) {
    case 'Input':
      return (
        <GetComponent.Input {...props.config} {...props}></GetComponent.Input>
      );

    case 'IList':
      return (
        <GetComponent.CList {...props.config} {...props}></GetComponent.CList>
      );
    case 'IUpload':
      return (
        <GetComponent.Input {...props.config} {...props}></GetComponent.Input>
      );
    default:
      return '';
  }
}

const AsyncComponent = (props) => {
  console.log('asnyc props', props, props.config.form);
  return (
    <>
      <Suspense fallback={<h4>加载中</h4>}>{switchComponent(props)}</Suspense>
    </>
  );
};

export default AsyncComponent;
